package com.example.demo.common;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.time.Duration;

public class Utils {

    public static WebDriver driver;
    public static WebDriver createDriver(){
        if(driver == null){

            ChromeOptions options = new ChromeOptions();
            //允许访问所有链接
            options.addArguments("--remote-allow-origins=*");

            driver = new ChromeDriver(options);
            //等待
            driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(2));

        }
        return driver;
    }

    public Utils(String url){
        driver = createDriver();

        driver.get(url);
    }
}
